<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Welcome</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

  </head>
  <body>
    <center>
    <h4>
      <a href="/user">User</a> 
      &nbsp;/&nbsp;
      <a href="/iot">IOT</a>
       &nbsp;/&nbsp;
      My Fund
    </h4>
    <br><br>

    <center>
      <span id="state" style="color:blue;"></span>
    </center>
    <table class="table">
      <tr>
        <td>Name</td>
        <td>Code</td>
        <td>Rate</td>
      </tr>

      <tbody id="contents">
        
      </tbody>

    </table>

    </center>
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>

    <script type="text/javascript">

      $(document).ready(function() {
        var t;
        fu_update();
      
        function fu_update()
        {
          get_fu_values();
          t = setTimeout(fu_update, 10000);
        }

        function get_fu_values() {
            $("#state").html('Loading ...');
            url = "/api/get_fu_values";
            $.get(url, function(data, status) {
                // console.log(data);
                d = JSON.parse(data);
                // alert(d[0][0]);
                contents = '';
                for (i=0; i<d.length; i++)
                {
                  contents += "<tr><td>" + d[i][0] + "</td><td>" + d[i][1] + "</td><td style='color:" + d[i][3] + "'>" + d[i][2] + "</td></tr>";
                }

                $("#state").html('Load ok!');
                $("#contents").html(contents);
            });
        }


      });

    </script>
  </body>
</html>